Tool
Type Parameters
Application-defined input type, must be @Serializable. The model produces JSON matching its schema; the agent deserializes via inputSerializer before calling execute.
Application-defined output type, must be @Serializable. Serialized into the model's tool-result message via outputSerializer, or summarized via toModelOutput if the raw output would be too verbose for the model.
Caller-supplied typed context propagated through the whole loop (set via callOptionsSchema, accessed inside execute as this.context).
Internally the agent loop always drives a Flow (the v6 alignment per tool.ts:68-71's AsyncIterable<OUTPUT> shape): a plain Tool wraps its single execute value in a one-emission flow; a StreamingTool passes its Flow straight through. The loop collects with one-step lookahead — non-final emissions become StreamEvent.ToolResult(preliminary = true), the last emission is the final result that lands in the model's message log.